# link: https://mp.weixin.qq.com/s/NTct2_AYhz4Z8q5MYtBQcA

import backtrader as bt
import pandas as pd
import datetime
import akshare as ak

pd.set_option('display.max_columns', None)


def get_data(code):
    df = ak.stock_zh_a_daily(symbol=code, adjust='qfq')
    # df.date = pd.to_datetime(df.date, format='%Y-%m-%d', utc=True)
    # df.set_index('date', inplace=True)
    df.index = pd.to_datetime(df.date)
    df.sort_index(inplace=True)

    return df


codes = ['sh600276', 'sh600519', 'sh603288']

# # 恒瑞医药
# data1 = get_data(codes[0])
# print(data1)
# print('data1')
# # 贵州茅台
# data2 = get_data(codes[1])
# # 海天味业
# data3 = get_data(codes[2])

# %%

# 实例化策略
cerebro = bt.Cerebro()

cerebro.broker.setcash(100000000.0)
cerebro.broker.setcommission(commission=0.001)

cerebro.broker = bt.brokers.BackBroker
cerebro.broker.set_slippage_fixed()

print(cerebro.broker.getcash())
cerebro.run()
# cerebro.plot()


